package com.hugh.hdfs.api.countsort;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @Author: Hugh
 * @Date: 2020/9/18
 */
public class HomeWorkReducer extends Reducer<IntWritable, NullWritable, IntWritable, IntWritable> {
    IntWritable total = new IntWritable();

    @Override
    protected void reduce(IntWritable key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for(NullWritable nullVal : values){
            total.set(total.get() + 1);
            context.write(total, key);
        }
    }
}
